package by.gravity.pvh.data;

import android.content.Context;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;

public class PreferenceDataManager {

	private static final String RATE = "RATE";

	private static final String LAST_UPDATE_TIME = "LAST_UPDATE_TIME";

	private static final String PREFERENCES = "PREFERENCES";

	public static void saveRate(Context context, String rate) {
		getEditor(context).putString(RATE, rate).commit();
	}

	public static String getRate(Context context) {
		return getSharedPreferences(context).getString(RATE, "");
	}

	public static void saveLastUpdateTime(Context context) {
		getEditor(context).putLong(LAST_UPDATE_TIME, System.currentTimeMillis()).commit();
	}

	public static long getLastUpdateTime(Context context) {
		return getSharedPreferences(context).getLong(LAST_UPDATE_TIME, 0);
	}

	private static Editor getEditor(Context context) {
		return getSharedPreferences(context).edit();
	}

	private static SharedPreferences getSharedPreferences(Context context) {
		return context.getSharedPreferences(PREFERENCES, 0);

	}
}
